<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            border: 0;
            box-sizing: border-box;
        }
        .box {
            position: relative;
            width: 200px;
            margin: 50px auto 0;
        }
        input {
            display: inline-block;
            width: 200px;
            height: 40px;
            padding-left: 8px;
            border: 1px solid orange;
            outline: none;
        }
        ul {
            display: none;
            position: absolute;
            left: 0;
            top: 40px;
            width: 200px;
            list-style: none;
            border: 1px solid orange;
            border-top: 0;
        }
        a {
            display: inline-block;
            font-size: 12px;
            color: black;
            width: 200px;
            height: 30px;
            line-height: 30px;
            padding-left: 8px;
            text-decoration: none;
            
        }
        a:hover {
            color: orange;
            background-color: #eee;
        }

    </style>
</head>
<body>
    <div class="box">
        <input type="search" placeholder="请输入你想要查询的内容">
        <ul>
            <li><a href="#">全部商品</a></li>
            <li><a href="#">小米11</a></li>
            <li><a href="#">小米10S</a></li>
            <li><a href="#">小米笔记本</a></li>
            <li><a href="#">小米手机</a></li>
            <li><a href="#">黑鲨4</a></li>
            <li><a href="#">空调</a></li>
        </ul>
    </div>
    <script>
        const ul = document.querySelector('ul')
        const input = document.querySelector('input')
        input.addEventListener('focus', function(){
            ul.style.display = 'block'
        })
        input.addEventListener('blur', function(){
            ul.style.display = 'none'
        })

    </script>
</body>

</html>